(deftemplate co-ordinate (slot x) (slot y))

(watch all)

(reset)

(defrule announce-co-ordinates
	"A rule that announces co-ordinates upon their creation"
	(co-ordinate (x ?x ) (y ?y))
	=>
	(printout t "A new co-ordinate created with x=" ?x " and y=" ?y)
)

(defrule points-not-equal
	"the two points cannot have the same value"
	( co-ordinate (x ?x) (y ~?x) )
	=>
	(printout t "Points are not equal" crlf)
)

(defrule predicate-constraint-test
	"To test use of Predicate-constraints"
	( co-ordinate (x ?x& :(> ?x 10)) (y ~?x) )
	=>
	(printout t "Points are not equal" crlf)
)

(defrule equality-constraint-test
	"To test use of Predicate-constraints"
	( co-ordinate (x ?x) (y ?y& =(+ 1 ?x)) )
	=>
	(printout t "Points are not equal and y is one more than x" crlf)
)

(assert (co-ordinate (x 0) (y 0)))
(assert (co-ordinate (x 12) (y 2)))
(assert (co-ordinate (x 11) (y 12)))

(run)